
#import "Comment.h"


@implementation Comment
- (instancetype) initWith:(NSDictionary*)dict{
    self = [super init];
    if (self != nil) {
        //        NSLog(@"%@",dict);
        NSDictionary *d1 = dict[@"Comment"];
        NSDictionary *d2 = dict[@"User"];
        NSArray<NSDictionary*> *d3 = dict[@"Replies"];
        NSDictionary *d4 = dict[@"Father"];
        
        [self setID:d1[@"ID"]];
        [self setContentID:d1[@"ContentID"]];
        [self setFatherID:d1[@"FatherID"]];
        [self setUserID:d1[@"UserID"]];
        [self setDate:[d1[@"Date"] integerValue]];
        [self setContent:d1[@"Content"]];
        [self setLikeNum:[d1[@"LikeNum"] integerValue]];
        
        [self setUserName:d2[@"Name"]];
        [self setUserAvatar:d2[@"Avatar"]];
        [self setUserGender:[d2[@"Gender"]integerValue]];
        
        if (d4 != nil) {
            [self setFatherName:d4[@"Name"]];
            [self setFatherAvatar:d4[@"Avatar"]];
            [self setFatherGender:[d4[@"Gender"]integerValue]];
        }
        
        if (d3 != nil) {
            self.replies = [[NSMutableArray alloc]init];
            for (NSDictionary *d in d3) {
                Comment *reply = [[Comment alloc]initWith:d];
                [self.replies addObject:reply];
            }
        }
        
    }
    return self;
}
@end
@implementation CommentReq
@end
